from douban.proxy import proxy
from urllib import request
from bs4 import BeautifulSoup
from douban.single_main import douban


def test_proxy():
    url = 'http://115.28.208.101:3000/'
    hdr = {
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
        'Accept-Encoding': 'none',
        'Accept-Language': 'en-US,en;q=0.8',
        'Connection': 'keep-alive'}
    opener = proxy()
    request.install_opener(opener.get_opener())
    # self.url="http://www.baidu.com"

    for i in range(0, 1):
        # proxy_handler = request.ProxyHandler({'http': 'http://127.0.0.1:8087'})
        # proxy_auth_handler = request.ProxyBasicAuthHandler()
        # opener = request.build_opener(proxy_handler, proxy_auth_handler)
        req = request.Request(url)
        f = request.urlopen(req)
        content = f.read().decode('utf-8')
        # soup = BeautifulSoup(content, "html5lib")
        # info = soup.find('span', text='您来自：').next_sibling
        print(content)


def tag():
    dou = douban()
    tags = dou.get_tag()


if __name__ == '__main__':
    # test_proxy()
    tag()
